<template>
	<view>
		<scroll-view class="right" scroll-y>
			<view class="item" v-for="(item,index) in options" :key="index" @click="tosto(index)">
				<view class="box">
					<text class="text1">{{item.name}}</text>
					<text class="text3">编号:[{{item.id}}]</text>
				</view>
				<view class="box">
					<text class="text2">供应商编号:{{item.supplier_id}}</text>
					<text class="text3">仓库编号:{{item.wid}}</text>
				</view>
				<view class="box">
					<text class="text2" style="color:#ff5500;">现有数量:{{item.num}}</text>
					<text class="text3" style="color:#ff5500;">警报数量:{{item.alarmnum}}</text>
				</view>
				<view class="br"></view>
			</view>
			<text v-if="options.length === 0">暂无数据</text>
		</scroll-view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				options:{}
			}
		},
		onLoad() {
			this.getdata();
		},
		methods:{
			async getdata(){
				var arr = [];
				const res = await this.Request({
					url:'api/stock/gealltdata'
				})
				this.option = res.data
				for(let i=0;i<res.data.length;i++){
					if(res.data[i].num>res.data[i].alarmnum){
						delete res.data[i]
					}
				}
				res.data.forEach((item) => arr.push(item))	
				this.options = arr;
			},
			tosto(e){
				uni.navigateTo({
					url:'/pages/public/stock/stoctmentord?id=' + this.options[e].id
				})
			},
		}
	}
</script>

<style lang="scss">
	.right{
		margin-left: 10px;
		.item{
			margin-top: 8px;
			position: relative;
			.br{
				margin-top: 2px;
				height: 1px;
				width: 100%;
				background-color: #999999;
			}
			.box{
				width: 100%;
				.text1{
					font-size: 120%;
					font-weight: 600;
				}
				.text2{
					color: #b7e481;
				}
				.text3{
					width: 130px;
					float:right;
				}
			}
		}
	}
</style>